// index.js
import {
    getHomeData
} from "../../request/request"
Page({
    data: {
        banner: [],
        channel: [],

        straightForList: [{
                id: 1,
                title: "TEFAL制造商1",
                price: "259.00",
                img: "http://yanxuan.nosdn.127.net/713daad73395a4f3d06f5dd07ed927d4.jpg"
            },
            {
                id: 2,
                title: "TEFAL制造商3",
                price: "259.00",
                img: "http://yanxuan.nosdn.127.net/713daad73395a4f3d06f5dd07ed927d4.jpg"
            },
            {
                id: 3,
                title: "TEFAL制造商4",
                price: "259.00",
                img: "http://yanxuan.nosdn.127.net/713daad73395a4f3d06f5dd07ed927d4.jpg"
            },
            {
                id: 4,
                title: "TEFAL制造商5",
                price: "259.00",
                img: "http://yanxuan.nosdn.127.net/713daad73395a4f3d06f5dd07ed927d4.jpg"
            }
        ],
        newGoodsList: [{
                img: "http://yanxuan.nosdn.127.net/aa49dfe878becf768eddc4c1636643a6.png",
                title: "蔓越莓曲奇 200克",
                price: "36.00"
            },
            {
                img: "http://yanxuan.nosdn.127.net/aa49dfe878becf768eddc4c1636643a6.png",
                title: "蔓越莓曲奇 200克",
                price: "36.00"
            },
            {
                img: "http://yanxuan.nosdn.127.net/aa49dfe878becf768eddc4c1636643a6.png",
                title: "蔓越莓曲奇 200克",
                price: "36.00"
            },
            {
                img: "http://yanxuan.nosdn.127.net/aa49dfe878becf768eddc4c1636643a6.png",
                title: "蔓越莓曲奇 200克",
                price: "36.00"
            },
        ],
        RecommendedList: [{
            id: 1,
            title: "可水洗舒柔丝羽绒枕",
            detail: "超细纤维，蓬松回弹",
            price: "59.00",
            img: "http://yanxuan.nosdn.127.net/0984c9388a2c3fd2335779da904be393.png"
        }, {
            id: 2,
            title: "可水洗舒柔丝羽绒枕",
            detail: "超细纤维，蓬松回弹",
            price: "59.00",
            img: "http://yanxuan.nosdn.127.net/0984c9388a2c3fd2335779da904be393.png"
        }, {
            id: 3,
            title: "可水洗舒柔丝羽绒枕",
            detail: "超细纤维，蓬松回弹",
            price: "59.00",
            img: "http://yanxuan.nosdn.127.net/0984c9388a2c3fd2335779da904be393.png"
        }, ],
        projectList: [{
            id: 1,
            img: "https://yanxuan.nosdn.127.net/14942996754171334.jpg",
            titile: "关爱他成长的每一个足迹",
            price: "99.00",
            detail: "专业运动品牌同厂，毛毛虫鞋子买二送一电风扇电风扇"
        }, {
            id: 2,
            img: "https://yanxuan.nosdn.127.net/14942996754171334.jpg",
            titile: "关爱他成长的每一个足迹",
            price: "99.00",
            detail: "专业运动品牌同厂，毛毛虫鞋子买二送一电风扇电风扇"
        }, {
            id: 3,
            img: "https://yanxuan.nosdn.127.net/14942996754171334.jpg",
            titile: "关爱他成长的每一个足迹",
            price: "99.00",
            detail: "专业运动品牌同厂，毛毛虫鞋子买二送一电风扇电风扇"
        }, {
            id: 4,
            img: "https://yanxuan.nosdn.127.net/14942996754171334.jpg",
            titile: "关爱他成长的每一个足迹",
            price: "99.00",
            detail: "专业运动品牌同厂，毛毛虫鞋子买二送一电风扇电风扇"
        }]
    },
    //点击首页搜索跳转函数
    goToPopup() {
        wx.navigateTo({
            url: '/pages/popup/popup',
        })
    },
    onLoad: function () {

        // getHomeData().then(res => {})
        getHomeData().then(res => {
            if (res.errno != 0) return
            // console.log(res);
            // console.log(res.data.banner);
            const {
                banner,
                channel
            } = res.data

            this.setData({
                banner: banner,
                channel: channel
            })
        }).catch(err => {})

    },
    onShow: function () {
        //获取当前页面的tabbar对象,设置他的active值为当前页面索引，解决tabbar闪烁乱跳问题
        let tabbarObj = this.getTabBar()
        tabbarObj.setData({
            active: 0
        })
    }
})